<template>
  <h1>{{ msg }}</h1>

  <p>
    <a href="https://vitejs.dev/guide/features.html" target="_blank">
      Vite Documentation
    </a>
    |
    <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
  </p>

  <button type="button" @click="add">count is: {{ num }}</button>
  <h3>{{ data.num }}</h3>
  <p>
    Edit
    <code>components/HelloWorld.vue</code> to test hot module replacement.
  </p>
</template>

<script setup>
  import {
    defineProps,
    reactive,
    computed
  } from 'vue'
  import {
    useStore
  } from 'vuex'
  import myData from '@/utils/myData.js'

  defineProps({
    msg: String
  })
  
  const store = useStore();

  const num = computed(() => store.state.num);
  
  const data = reactive(myData);
  
  const add = () => {
    store.commit('setNum', num.value + 1);
    data.num ++;
  };
</script>

<style scoped>
  a {
    color: #42b983;
  }
</style>
